REM script to start credentials server
ECHO starting credentials server

SET CRED_STORE_CLASSPATH=.
SET CRED_STORE_HOME=%1

IF (%JAVA_HOME%=="") goto nojavahome

SET CRED_STORE_HOME=%CD%\..

CALL %CRED_STORE_HOME%\bin\setup-environment.bat %CRED_STORE_HOME%

REM Setting Java options
SET JAVA_VM_ARGS=-Djava.util.logging.config.file=%CRED_STORE_CONFIG_DIR%\logger.properties 
SET JAVA_VM_ARGS=%JAVA_VM_ARGS% -Xms40m -Xmx256m -Xdebug -Xrunjdwp:transport=dt_socket,address=11555,server=y,suspend=n

REM now invoke the application

SET CRED_STORE_SERVER_ARGS=-springconfig %CRED_STORE_CONFIG_DIR%\security-server-config.xml
SET CRED_STORE_SERVER_ARGS=%CRED_STORE_SERVER_ARGS% -props %CRED_STORE_CONFIG_DIR%\cred-server.properties

%JAVA_HOME%\bin\java %JAVA_VM_ARGS% -cp %CRED_STORE_CLASSPATH% com.obixlabs.security.credentialsstore.server.SecurityServer %CRED_STORE_SERVER_ARGS% 
goto end

:nojavahome
ECHO The JAVA_HOME environment variable has not been set. 

:noServerHome
ECHO USAGE: start-server.bat [credentials-server home directory]

:end